/*
Navicat MySQL Data Transfer

Source Server         : root@local
Source Server Version : 50632
Source Host           : 127.0.0.1:3306
Source Database       : fugaocrm_bak

Target Server Type    : MYSQL
Target Server Version : 50632
File Encoding         : 65001

Date: 2017-02-27 12:58:12
*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------
-- Table structure for fg_company
-- ----------------------------
DROP TABLE IF EXISTS `fg_company`;
CREATE TABLE `fg_company` (
  `company_id` int(20) NOT NULL AUTO_INCREMENT,
  `company_name` varchar(200) DEFAULT NULL,
  `company_code` varchar(20) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_company
-- ----------------------------

-- ----------------------------
-- Table structure for fg_contract
-- ----------------------------
DROP TABLE IF EXISTS `fg_contract`;
CREATE TABLE `fg_contract` (
  `contract_id` int(20) NOT NULL AUTO_INCREMENT,
  `project_id` int(20) DEFAULT NULL,
  `contract_code` varchar(50) DEFAULT NULL,
  `is_sign` varchar(2) DEFAULT NULL COMMENT '是否签订：Y-是，N-否',
  `is_delivery` varchar(2) DEFAULT NULL COMMENT '是否交货：Y-是，N-否',
  `sign_date` datetime DEFAULT NULL,
  `delivery_date` datetime DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`contract_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_contract
-- ----------------------------

-- ----------------------------
-- Table structure for fg_contract_detail
-- ----------------------------
DROP TABLE IF EXISTS `fg_contract_detail`;
CREATE TABLE `fg_contract_detail` (
  `contract_detail_id` int(20) NOT NULL AUTO_INCREMENT,
  `contract_id` int(20) DEFAULT NULL,
  `project_id` int(20) DEFAULT NULL,
  `detail_type` varchar(10) DEFAULT NULL COMMENT '合同明细类型：BILL-开票类型，PAY-收款类型',
  `is_billing` varchar(2) DEFAULT NULL COMMENT '是否开票：Y-是，N-否',
  `is_payment` varchar(2) DEFAULT NULL COMMENT '是否付款：Y-是，N-否',
  `billing_type` varchar(20) DEFAULT NULL,
  `billing_rate` varchar(20) DEFAULT NULL,
  `payment_rate` varchar(20) DEFAULT NULL,
  `billing_money` numeric(9,2) DEFAULT NULL,
  `billing_date` datetime DEFAULT NULL,
  `payment_date` datetime DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`contract_detail_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_contract_detail
-- ----------------------------

-- ----------------------------
-- Table structure for fg_customer
-- ----------------------------
DROP TABLE IF EXISTS `fg_customer`;
CREATE TABLE `fg_customer` (
  `customer_id` int(20) NOT NULL AUTO_INCREMENT,
  `customer_company_id` int(20) DEFAULT NULL,
  `customer_name` varchar(45) DEFAULT NULL,
  `customer_mobile` varchar(25) DEFAULT NULL,
  `customer_email` varchar(45) DEFAULT NULL,
  `title` varchar(45) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`customer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_customer
-- ----------------------------

-- ----------------------------
-- Table structure for fg_customer_company
-- ----------------------------
DROP TABLE IF EXISTS `fg_customer_company`;
CREATE TABLE `fg_customer_company` (
  `customer_company_id` int(20) NOT NULL AUTO_INCREMENT,
  `customer_company_name` varchar(100) DEFAULT NULL,
  `customer_company_adress` varchar(100) DEFAULT NULL,
  `industry_name` varchar(45) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`customer_company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_customer_company
-- ----------------------------

-- ----------------------------
-- Table structure for fg_partner_company
-- ----------------------------
DROP TABLE IF EXISTS `fg_partner_company`;
CREATE TABLE `fg_partner_company` (
  `partner_company_id` int(20) NOT NULL AUTO_INCREMENT,
  `partner_company_name` varchar(200) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`partner_company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_partner_company
-- ----------------------------

-- ----------------------------
-- Table structure for fg_partner_company_detail
-- ----------------------------
DROP TABLE IF EXISTS `fg_partner_company_detail`;
CREATE TABLE `fg_partner_company_detail` (
  `partner_detail_id` int(20) NOT NULL AUTO_INCREMENT,
  `partner_company_id` int(20) DEFAULT NULL,
  `project_id` int(20) DEFAULT NULL,
  `is_shipment` varchar(2) DEFAULT NULL COMMENT '是否出货：Y-是，N-否',
  `is_billing` varchar(2) DEFAULT NULL COMMENT '是否开票：Y-是，N-否',
  `is_payment` varchar(2) DEFAULT NULL COMMENT '是否付款：Y-是，N-否',
  `shipment_date` datetime DEFAULT NULL,
  `billing_type` varchar(10) DEFAULT NULL COMMENT '开票类型',
  `billing_date` datetime DEFAULT NULL,
  `payment_date` datetime DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`partner_detail_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_partner_company_detail
-- ----------------------------

-- ----------------------------
-- Table structure for fg_partner_contact
-- ----------------------------
DROP TABLE IF EXISTS `fg_partner_contact`;
CREATE TABLE `fg_partner_contact` (
  `contact_id` int(20) NOT NULL AUTO_INCREMENT,
  `partner_company_id` int(20) DEFAULT NULL,
  `contact_name` varchar(45) DEFAULT NULL,
  `contact_mobile` varchar(25) DEFAULT NULL,
  `contact_email` varchar(45) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`contact_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_partner_contact
-- ----------------------------

-- ----------------------------
-- Table structure for fg_partner_product
-- ----------------------------
DROP TABLE IF EXISTS `fg_partner_product`;
CREATE TABLE `fg_partner_product` (
  `partner_product_id` int(20) NOT NULL AUTO_INCREMENT,
  `partner_company_id` int(20) DEFAULT NULL,
  `partner_product_name` varchar(200) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`partner_product_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_partner_product
-- ----------------------------

-- ----------------------------
-- Table structure for fg_position
-- ----------------------------
DROP TABLE IF EXISTS `fg_position`;
CREATE TABLE `fg_position` (
  `position_id` int(20) NOT NULL AUTO_INCREMENT,
  `position_name` varchar(200) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`position_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_position
-- ----------------------------

-- ----------------------------
-- Table structure for fg_project
-- ----------------------------
DROP TABLE IF EXISTS `fg_project`;
CREATE TABLE `fg_project` (
  `project_id` int(20) NOT NULL AUTO_INCREMENT,
  `project_name` varchar(200) DEFAULT NULL,
  `customer_id` int(11) DEFAULT NULL,
  `customer_company_id` int(20) DEFAULT NULL,
  `staff_id` int(11) DEFAULT NULL,
  `company_id` int(20) DEFAULT NULL,
  `offer` varchar(200) DEFAULT NULL COMMENT '报价',
  `project_schedule` varchar(2000) DEFAULT NULL,
  `project_status` varchar(10) DEFAULT NULL COMMENT '项目状态；1-项目机会，2-项目执行，3-项目废除，4-项目完成',
  `is_repair` varchar(10) DEFAULT NULL COMMENT '是否需要维护；Y-需要维护，N-不需要维护',
  `repair_start_date` datetime DEFAULT NULL,
  `repair_end_date` datetime DEFAULT NULL,
  `expected_deal_date` datetime DEFAULT NULL COMMENT '预定成交日期',
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`project_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_project
-- ----------------------------

-- ----------------------------
-- Table structure for fg_project_log
-- ----------------------------
DROP TABLE IF EXISTS `fg_project_log`;
CREATE TABLE `fg_project_log` (
  `log_id` int(20) NOT NULL AUTO_INCREMENT,
  `project_id` int(20) DEFAULT NULL,
  `todo_something` varchar(2000) DEFAULT NULL,
  `todo_date` datetime DEFAULT NULL,
  `is_done` varchar(10) DEFAULT NULL COMMENT '是否做了；Y-做了，N-没有做',
  `done_date` datetime DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_project_log
-- ----------------------------

-- ----------------------------
-- Table structure for fg_project_pafrol_record
-- ----------------------------
DROP TABLE IF EXISTS `fg_project_pafrol_record`;
CREATE TABLE `fg_project_pafrol_record` (
  `patrol_id` int(20) NOT NULL AUTO_INCREMENT,
  `project_id` int(20) DEFAULT NULL,
  `next_something` varchar(2000) DEFAULT NULL,
  `staff_id` int(20) DEFAULT NULL,
  `is_complete` varchar(10) DEFAULT NULL,
  `patrol_date` datetime DEFAULT NULL,
  `created_user` varchar(200) DEFAULT NULL,
  `modified_user` varchar(200) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(200) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`patrol_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_project_pafrol_record
-- ----------------------------

-- ----------------------------
-- Table structure for fg_project_repair_recode
-- ----------------------------
DROP TABLE IF EXISTS `fg_project_repair_recode`;
CREATE TABLE `fg_project_repair_recode` (
  `repair_id` int(20) NOT NULL AUTO_INCREMENT,
  `project_id` int(20) DEFAULT NULL,
  `done_something` varchar(2000) DEFAULT NULL,
  `repair_date` datetime DEFAULT NULL,
  `staff_id` int(20) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`repair_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_project_repair_recode
-- ----------------------------

-- ----------------------------
-- Table structure for fg_remind_message
-- ----------------------------
DROP TABLE IF EXISTS `fg_remind_message`;
CREATE TABLE `fg_remind_message` (
  `remind_message_id` int(20) NOT NULL AUTO_INCREMENT,
  `contract_detail_id` int(20) DEFAULT NULL,
  `is_billing` varchar(2) COLLATE utf8_bin DEFAULT NULL COMMENT '是否开票：Y-是，N-否',
  `is_payment` varchar(2) COLLATE utf8_bin DEFAULT NULL COMMENT '是否付款：Y-是，N-否',
  `project_id` int(20) DEFAULT NULL,
  `partner_detail_id` int(20) DEFAULT NULL,
  `log_id` int(20) DEFAULT NULL,
  `patrol_id` int(20) DEFAULT NULL,
  `remind_content` varchar(2000) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`remind_message_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_remind_message
-- ----------------------------

-- ----------------------------
-- Table structure for fg_staff
-- ----------------------------
DROP TABLE IF EXISTS `fg_staff`;
CREATE TABLE `fg_staff` (
  `staff_id` int(20) NOT NULL AUTO_INCREMENT,
  `user_id` int(20) DEFAULT NULL,
  `company_id` int(20) DEFAULT NULL,
  `position_id` int(20) DEFAULT NULL,
  `staff_name` varchar(45) DEFAULT NULL,
  `staff_mobile` varchar(25) DEFAULT NULL,
  `permission` varchar(10) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`staff_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_staff
-- ----------------------------
INSERT INTO `fg_staff` VALUES ('1', '1', null, null, '系统管理员', '', '2', null, null, '2017-01-01 00:00:00', '2017-01-01 00:00:00', '0');

-- ----------------------------
-- Table structure for fg_task
-- ----------------------------
DROP TABLE IF EXISTS `fg_task`;
CREATE TABLE `fg_task` (
  `task_id` int(20) NOT NULL AUTO_INCREMENT,
  `task_name` varchar(45) DEFAULT NULL,
  `time_space` varchar(45) DEFAULT NULL COMMENT '执行时间间隔：w-周，d-天，m-分，s-秒',
  `last_time` datetime DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`task_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_task
-- ----------------------------

BEGIN;
INSERT INTO `fg_task` VALUES ('1', '销售日志', '1', '2017-01-01 00:00:00', null, null, null, null, '0'), ('2', '合作商付款', '1', null, null, null, null, null, '0'), ('3', '合同开票', '1', null, null, null, null, null, '0'), ('4', '合同收款', '1', null, null, null, null, null, '0'), ('5', '运维巡检', '1', null, null, null, null, null, '0');
COMMIT;

-- ----------------------------
-- Table structure for fg_user
-- ----------------------------
DROP TABLE IF EXISTS `fg_user`;
CREATE TABLE `fg_user` (
  `user_id` int(20) NOT NULL AUTO_INCREMENT,
  `user_name` varchar(45) DEFAULT NULL,
  `password` varchar(45) DEFAULT NULL,
  `created_user` varchar(45) DEFAULT NULL,
  `modified_user` varchar(45) DEFAULT NULL,
  `created_date` datetime DEFAULT NULL,
  `modified_date` datetime DEFAULT NULL,
  `is_delete` int(1) DEFAULT '0' COMMENT '删除标记；1-删除，0-未删除',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Table structure for fg_code
-- ----------------------------
DROP TABLE IF EXISTS `fg_code`;
CREATE TABLE `fg_code` (
  `id` int(20) NOT NULL AUTO_INCREMENT,
  `code_type` varchar(20) DEFAULT NULL,
  `code` varchar(20) DEFAULT NULL,
  `code_lable` varchar(20) DEFAULT NULL,
  `name` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of fg_user
-- ----------------------------
INSERT INTO `fg_user` VALUES ('1', 'sysadmin', '123456', null, null, '2017-01-01 00:00:00', '2017-01-01 00:00:00', '0');
INSERT INTO `fg_code` VALUES ('1', 'contractSeq', 'seq', '1', '合同序列号');
